try:
    file = open("text.txt","w") # 打开文件
    s = "hello world"
    file.write(s) # 操作文件
except:
    print("操作异常")
finally:
    file.close()  # 关闭文件
    print("关闭文件")

